home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Mode Examples / Igor-Example.igor < prev    next >
Encoding:
Text File  |  2000-10-30  |  3.5 KB  |  152 lines

  1. // Igor-Example.igor
  2. //
  3. // Included in the Alpha distribution as an example of the Igor mode.
  4. // Igor mode is part of the standard Alpha distribution.
  5. //
  6. // Additional information about Igor Pro, a data analysis and graphing package
  7. // can be found at:
  8. //      <http://www.wavemetrics.com/>
  9. //
  10. // Jonathan Guyer is the author of Igor mode.  His Igor macro site is at:
  11. //      <http://www.his.com/~jguyer/IGOR/index.html>
  12.  
  13. // IgorMacros.igor
  14.  
  15. #pragma rtGlobals=1        // Use modern global access method.
  16.  
  17. Macro ClearRegion()
  18.     PauseUpdate; Silent 1
  19.     if (CmpStr(WinName(0, 1), "") == 0)
  20.         Beep
  21.         print "No Top Graph."
  22.     else
  23.          if ( CmpStr( CsrWave(A), CsrWave(B)) == 0 )
  24.             $CsrWave(A)[min(pcsr(A), pcsr(B)), max(pcsr(A),pcsr(B))]=NaN
  25.         else
  26.             Beep
  27.             print "Cursors must be on same wave"
  28.         endif
  29.     endif
  30. EndMacro
  31.  
  32. Macro DeleteRegion()
  33.     PauseUpdate; Silent 1
  34.     if (CmpStr(WinName(0, 1), "") == 0)
  35.         Beep
  36.         print "No Top Graph."
  37.     else
  38.          if ( CmpStr( CsrWave(A), CsrWave(B)) == 0 )
  39.             if (CmpStr(XWaveName(WinName(0, 1), CsrWave(A)), "" )==0)
  40.                 DeletePoints min(pcsr(A), pcsr(B)),  Abs(pcsr(A)-pcsr(B))+1, $CsrWave(A)
  41.             else
  42.                 DeletePoints min(pcsr(A), pcsr(B)),  Abs(pcsr(A)-pcsr(B))+1, $CsrWave(A), $CsrXWave(A)
  43.             endif
  44.             if (pcsr(A) > pcsr(B))
  45.                 Cursor A, $CsrWave(A), pcsr(B)+1
  46.             else
  47.                 Cursor B, $CsrWave(A), pcsr(A)+1
  48.             endif
  49.         else
  50.             Beep
  51.             print "Cursors must be on same wave"
  52.         endif
  53.     endif
  54. EndMacro
  55.  
  56. Macro ClipToRegion()
  57.     PauseUpdate; Silent 1
  58.     if (CmpStr(WinName(0, 1), "") == 0)
  59.         Beep
  60.         print "No Top Graph."
  61.     else
  62.          if ( CmpStr( CsrWave(A), CsrWave(B)) == 0 )
  63.             if (CmpStr(XWaveName(WinName(0, 1), CsrWave(A)), "" )==0)
  64.                 DeletePoints max(pcsr(A), pcsr(b))+1, numpnts($CsrWave(A))-max(pcsr(A), pcsr(B))-1, $CsrWave(A)
  65.                 DeletePoints 0, min(pcsr(A), pcsr(B)),  $CsrWave(A)
  66.             else
  67.                 DeletePoints max(pcsr(A), pcsr(b))+1, numpts(CsrWave(A))-max(pcsr(A), pcsr(B))-1, $CsrWave(A), $CsrXWave(A)
  68.                 DeletePoints 0, min(pcsr(A), pcsr(B)),  $CsrWave(A), $CsrXWave(A)
  69.             endif
  70.             if (pcsr(A) > pcsr(B))
  71.                 Cursor A, $CsrWave(A), numpnts($CsrWave(A))
  72.                 Cursor B, $CsrWave(A), 0
  73.             else
  74.                 Cursor B, $CsrWave(A), numpnts($CsrWave(A))
  75.                 Cursor A, $CsrWave(A), 0
  76.             endif
  77.         else
  78.             Beep
  79.             print "Cursors must be on same wave"
  80.         endif
  81.     endif
  82. EndMacro
  83.  
  84. Proc DefaultStyle() : GraphStyle
  85.     PauseUpdate; Silent 1        | modifying window...
  86.     Modify/Z tick=2
  87.     Modify/Z mirror=1
  88.     Modify/Z minor=1
  89.     Modify/Z standoff=0
  90. EndMacro
  91.  
  92. Macro CloseAllGraphs()
  93.     string topwindowname
  94.     
  95.     silent 1
  96.     do
  97.         topwindowname = WinName(0, 1)
  98.         if (strlen(topwindowname))
  99.            DoWindow/K $topwindowname
  100.         endif
  101.     while (strlen(topwindowname) != 0)
  102. EndMacro
  103.  
  104. Macro CatWaves(a, b)
  105.     String a,b
  106.     Prompt a, "First Wave"
  107.     Prompt b, "Second Wave"
  108.  
  109.     Variable newlen, lena, lenb
  110.     lena = numpnts($a)
  111.     lenb = numpnts($b)
  112.     newlen=lena+lenb
  113.     InsertPoints lena, lenb, $a
  114.     $a[lena,newlen-1]=$b[p-lena]
  115. EndMacro
  116.  
  117. Macro ScaleRegion(m)
  118. Variable m
  119. Prompt m, "Multiplication Factor"
  120.     Variable c, d
  121.  
  122.     PauseUpdate; Silent 1
  123.     if (CmpStr(WinName(0, 1), "") == 0)
  124.         Beep
  125.         print "No Top Graph."
  126.     else
  127.          if ( CmpStr( CsrWave(A), CsrWave(B)) == 0 )
  128.             c = Min(pcsr(A), pcsr(B))
  129.             d = Max(pcsr(A), pcsr(B))
  130.             $CsrWave(A)[c, d] *= m
  131.         else
  132.             Beep
  133.             print "Cursors must be on same wave"
  134.         endif
  135.     endif
  136. EndMacro
  137.  
  138. Macro LabelX_Temp()
  139.     Label bottom "\F'Palatino'\Z18Temperature [K]"
  140. EndMacro
  141.  
  142. Macro LabelX_Field()
  143.     Label bottom "\F'Palatino'\Z18Field [T]"
  144. EndMacro
  145.  
  146. Macro LabelY_Resist()
  147.     Label left "\F'New York'\Z18 [\[0\F'Symbol'W\F]0]"
  148. EndMacro
  149.  
  150. Macro LabelY_M_emu()
  151.     Label left "\F'Palatino'\Z18 M [emu]"
  152. EndMacro